<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
//登陆后的操作
Route::group(['middleware'=>'auth'],function(){
    Route::post('/question/create','QuestionController@store');
    //添加回复
    Route::post('/answer/create','AnswerController@create');
    //用户设置
    Route::get('/user/set','UserController@set');
    Route::post('/user/set','UserController@setStore');
    //用户提醒
    Route::get('/user/msg','UserController@msg');
    //修改头像
    Route::post('/user/checkFace','UserController@checkFace');

    //文本编辑器
    Route::post('/question/upload','QuestionController@upload');
    //点赞
    Route::post('/answer/zan','AnswerController@zan');
    //我的文章
    Route::get('/user/myquestion','UserController@myQuestion');
    //收藏文章
    Route::post('/question/collection/{question}','QuestionController@collection');
    //采纳回复
    Route::post('/answer/caina/{answer}','AnswerController@caina');
    //消息提醒
    Route::get('/user/msg/{user}','UserController@msg');
    //消息清楚
    Route::post('/msg/clear','UserController@clearMsg');
    //清楚全部消息
    Route::post('/user/clearAll','UserController@clearAll');
    //签到
    Route::post('/sign','UserController@sign');

});

//登录登出
Route::get('/login','LoginController@login');
Route::post('/login','LoginController@loginStore');
Route::get('/logout','LoginController@logout');
//注册
Route::get('/reg','LoginController@reg');
Route::post('/reg','LoginController@store');
//用户主页
Route::get('/user/{user}','UserController@index');
//主页
Route::get('/','IndexController@index');

//文章详情
Route::get('/question/{question}/show','QuestionController@show');
//文章列表
Route::get('/question','QuestionController@index');
//添加文章
Route::get('/question/create','QuestionController@create');
//搜索文章
Route::get('/search','SearchController@search');


//后台登录
Route::group(['prefix'=>'admin'],function (){
    //后台登录主页
    Route::get('/login','LoginController@adminLogin');
    //后台登录逻辑
    Route::post('/login','LoginController@adminLoginStore');
    //需要后台登录的页面
    Route::group(['middleware'=>'auth:admin'],function (){
        //后台登录后主页面
        Route::get('/home','AdminController@index');

        //退出后台
        Route::get('/logout','LoginController@adminLogout');

        //欢迎页面
        Route::get('welcome','AdminController@welcome');



        Route::group(["middleware"=>"can:文章管理"],function(){
            //后台文章列表
            Route::get('question','AdminController@qlist');
            //加精
            Route::post('jing/{question}','AdminController@jing');
            //置顶
            Route::post('top/{question}','AdminController@top');
            //删除
            Route::post('/question/delete/{question}','AdminController@questionDelete');
            //多项删除
            Route::post('/question/deleteall','AdminController@questionDeleteAll');
        });
        Route::group(["middleware"=>"can:用户管理"],function() {
            //后台用户管理列表
            Route::get('/user','AdminController@ulist');

            //删除单个用户
            Route::post('user/delete/{user}','AdminController@userDelete');

            //删除多个用户
            Route::post('/user/deleteall','AdminController@userDeleteAll');

        });
        Route::group(["middleware"=>"can:系统管理"],function() {

        });
        Route::group(["middleware"=>"can:管理员管理"],function() {
            //管理员列表
            Route::get('/user/list','AdminUserController@ulist');
            //管理员添加
            Route::get('/user/add','AdminUserController@add');
            //添加逻辑
            Route::post('/user/adduser','AdminUserController@store');
            //管理员角色关系
            Route::get('/user/{adminUser}/role','AdminUserController@role');
            //管理员角色关系逻辑
            Route::post('/user/{adminUser}/role','AdminUserController@roleStore');
            //角色列表
            Route::get('/role/list','AdminRoleController@rlist');
            //角色添加
            Route::get('/role/add','AdminRoleController@add');
            //添加逻辑
            Route::post('/role/add','AdminRoleController@store');
            //管理员角色关系
            Route::get('/role/{adminRole}/permission','AdminRoleController@permission');
            //管理员角色关系逻辑
            Route::post('/role/{adminRole}/permission','AdminRoleController@permissionStore');
            //权限列表
            Route::get('/permission/list','AdminPermissionController@plist');
            //权限添加
            Route::get('/permission/add','AdminPermissionController@add');
            //添加逻辑
            Route::post('/permission/add','AdminPermissionController@store');
        });



    });
});





